package cn.duke.pay.common;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class ServiceFactory implements ApplicationContextAware {

	private static ApplicationContext context;
	
	@Override
	public void setApplicationContext(ApplicationContext context)
			throws BeansException {
		setContext(context);
		
	}
	
	public static Object getBean(String beanName){
		return getContext().getBean(beanName);
		
	}

	public static void setContext(ApplicationContext context) {
		ServiceFactory.context = context;
	}

	public static ApplicationContext getContext() {
		return context;
	}
	

	
}
